<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
session_start(); //we need to call PHP's session object to access it through CI
class Home extends CI_Controller {

 function __construct()
 {
   parent::__construct();
   $this->load->model('ptdomainmodel');
   $this->load->model('usiaUserModel');
//   $config['is_ajax_paging']    = TRUE; //default FALSE
 }

 function index()
 {
   if($this->session->userdata('logged_in'))
   {
   		$session_data = $this->session->userdata('logged_in');
     	$userid = $session_data['userid'];
     	$username = $session_data['username'];
     	$gender = $session_data['gender'];
     	$usia = $this->usiaUserModel->getUsia($userid)->result();
		if (count($usia) > 1) {
     		for ($j2 = 0; $j2 < count($usia); $j2++) {
     			$age[$j2] = $usia[$j2]->USIAID;
     		}
     		$usiaid = max($age);
     	} else {
     		$usiaid = $usia[0]->USIAID;
     	}
     	$ptuser = $this->ptdomainmodel->getSkorDomain($userid,$usiaid)->result();
     	if($ptuser != null){
     		redirect('recommendationControl/recommendation','refresh');
     	}else {
     		redirect('kuesionerControl/index','refresh');
     	}
//
//     $this->load->view('kuesionerForm1', $data);

     redirect('kuesionerControl/index','refresh');

   }
   else
   {
     //If no session, redirect to login page
     redirect('userPageControl', 'refresh');
   }
 }

 function logout()
 {
   $this->session->unset_userdata('logged_in');
   session_destroy();
   redirect('userPageControl', 'refresh');
 }

}

?>
